#ifndef	__SBCS_CODE_PAGE_ENCODING_H__
#define	__SBCS_CODE_PAGE_ENCODING_H__

namespace BFX
{

/////////////////////////////////////////////////////////////////////////////
// REFSBCSCodePageEncoding

class REFSBCSCodePageEncoding : public REFBaseCodePageEncoding
{
	//
	// Constructors
	//
public:
	REFSBCSCodePageEncoding(int nCodePage);
	REFSBCSCodePageEncoding(int nCodePage, int nDataCodePage);

	//
	// Overrides
	//
	virtual int GetMaxByteCount(int nCharCount) const;
	virtual int GetMaxCharCount(int nCount) const;

	virtual int GetByteCount(const UCHAR* pChars, int nCount) const;
	virtual int GetBytes(const UCHAR* pChars, int nCharCount, OUT BYTE* pBytes, int nByteCount) const;

	virtual int GetCharCount(const BYTE* pBytes, int nCount, REFDecoder* pDecoder) const;
	virtual int GetChars(const BYTE* pBytes, int nByteCount, OUT UCHAR* pChars, int nCharCount, REFDecoder* pDecoder) const;

protected:

	// We have a managed code page entry, so load our tables
	virtual void LoadManagedCodePage();

	//
	// Attributes
	//
	// Pointers to our memory section parts
	UCHAR*	m_pMapBytesToUnicode;		// char 256
	BYTE*	m_pMapUnicodeToBytes;		// byte 65536
	int*	m_pMapCodePageCached;		// to remember which CP is cached

	// byteUnknown is used for default fallback only
	BYTE	m_byteUnknown;
	UCHAR	m_charUnknown;
};

}	//	namespace BFX

#endif	//	__SBCS_CODE_PAGE_ENCODING_H__
